<template>
    <div>
        <div class="archives-wrapper">
            <div class="archive-separator" v-for="(val,id) in dayList" :key="id">
                <div class="title-time">{{val.name}},2020</div>
                <div class="archives-list">
                    <div class="archives-item" v-for="(items,index) in list" :key="index" v-if="items.day==val.val" @click="goDetail(items.id)">
                        <div>
                            <p class="archives-time">{{items.time}}</p>
                            <h3 class="archives-title">{{items.title}}</h3>
                            <div class="archives-operation">
                                <p class="archives-tag" v-for="(item,index1) in items.icon" :key="index1">{{item}}</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            list: [],
            dayList: [
                { name: '十月', val: '10' },
                { name: '九月', val: '09' },
                { name: '八月', val: '08' },
                { name: '七月', val: '07' },
            ],
        }
    },
    methods: {
        goDetail(v) {
            this.$router.push('/Details?id=' + v)
        },
        getList() {
            let _this = this
            this.$axios.get(this.$api.list).then(function (res) {
                _this.list = res.data.data || []
                for (const obj of _this.list) {
                    let v = obj.time.split('月')[0]
                    _this.$set(obj, 'day', v.substring(v.length - 2))
                }
            })
        },
    },
}
</script>

<style scoped>
.archives-wrapper {
    margin: 0px auto 40px;
    min-height: calc(100vh - 270px);
}
.archive-separator {
    margin: 10px 0;
    color: #3f51b5;
    font-size: 16px;
    font-weight: bold;
    margin-top: 30px;
}
.main-wrapper {
    flex: 1;
    background: #f6f6f6;
    padding: 0 15px;
}
.archives-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
}
.archives-item {
    width: calc(50% - 10px);
    box-sizing: border-box;
    padding: 16px 20px 0;
    background: #fff;
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(151, 151, 151, 0.58);
    margin-bottom: 20px;
}
.archives-time {
    margin: 0 0 10px;
    line-height: 14px;
    font-size: 13px;
    font-weight: bold;
    color: #727272;
    overflow: hidden;
}
.archives-title {
    font-size: 18px;
    margin-bottom: 0;
    padding-bottom: 16px;
}
.archives-operation {
    border-top: 1px solid #ddd;
    display: flex;
    padding: 12px 20px 8px;
    margin: 0 -20px;
}
.archives-tag {
    border-radius: 2px;
    background: #8bc34a;
    padding: 0 16px;
    line-height: 28px;
    color: rgba(255, 255, 255, 0.8);
}
.title-time {
    margin-bottom: 20px;
}
</style>